package com.central.common.feign.fallback;

import com.central.common.feign.UserService;
import com.central.common.model.SysUser;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

/**
 * userService降级工场
 * @author ly
 * @email 664162337@qq.com
 * @date 2020/9/25 15:02
 */
@Slf4j
public class UserServiceFallbackFactory implements FallbackFactory<UserService> {

    @Override
    public UserService create(Throwable throwable) {
        return id -> {
            log.error("通过 id 查询用户异常:{}", id, throwable);
            return new SysUser();
        };
    }
}
